1 /*
2  * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
3  * Copyright (c) 2012 - Andre Roth <neolynx@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation version 2.1 of the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18  *
19  */
20 
21 /**
22  * @file desc_sat.h
23  * @ingroup descriptors
24  * @brief Provides the descriptors for the satellite delivery system descriptor
25  * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
26  * @author Mauro Carvalho Chehab
27  * @author Andre Roth
28  *
29  * @par Relevant specs
30  * The descriptor described herein is defined at:
31  * - ETSI EN 300 468 V1.11.1
32  *
33  * @par Bug Report
34  * Please submit bug reports and patches to linux-media@vger.kernel.org
35  */
36 
37 module libdvbv5_d.desc_sat;
38 
39 import libdvbv5_d.descriptors: dvb_desc;
40 import libdvbv5_d.dvb_fe: dvb_v5_fe_parms;
41 
42 extern (C):
43 
44 /**
45  * @struct dvb_desc_sat
46  * @ingroup descriptors
47  * @brief Structure containing the satellite delivery system descriptor
48  *
49  * @param type			descriptor tag
50  * @param length		descriptor length
51  * @param next			pointer to struct dvb_desc
52  * @param frequency		frequency in kHz
53  * @param orbit			orbital position in degrees (multiplied by 10)
54  * @param west_east		west east flag. 0 = west, 1 = east
55  * @param polarization		polarization. 0 = horizontal, 1 = vertical,
56  *				2 = left, 3 = right.
57  * @param roll_off		roll off alpha factor. 0 = 0.35, 1 = 0.25,
58  * 				2 = 0.20, 3 = reserved.
59  * @param modulation_system	modulation system. 0 = DVB-S, 1 = DVB-S2.
60  * @param modulation_type	modulation type. 0 = auto, 1 = QPSK, 2 = 8PSK,
61  *				3 = 16-QAM (only for DVB-S2).
62  * @param symbol_rate		symbol rate in Kbauds.
63  * @param fec			inner FEC (convolutional code)
64  */
65 struct dvb_desc_sat
66 {
67     import std.bitmanip : bitfields;
68     align (1):
69 
70     ubyte type;
71     ubyte length;
72     dvb_desc* next;
73 
74     uint frequency;
75     ushort orbit;
76 
77     mixin(bitfields!(
78         ubyte, "modulation_type", 2,
79         ubyte, "modulation_system", 1,
80         ubyte, "roll_off", 2,
81         ubyte, "polarization", 2,
82         ubyte, "west_east", 1));
83 
84     union
85     {
86         align (1):
87 
88         uint bitfield;
89 
90         struct
91         {
92             import std.bitmanip : bitfields;
93             align (1):
94 
95             mixin(bitfields!(
96                 uint, "fec", 4,
97                 uint, "symbol_rate", 28));
98         }
99     }
100 }
101 
102 // struct dvb_v5_fe_parms;
103 
104 /**
105  * @brief Initializes and parses the satellite delivery system descriptor
106  * @ingroup descriptors
107  *
108  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
109  * @param buf	buffer containing the descriptor's raw data
110  * @param desc	pointer to struct dvb_desc to be allocated and filled
111  *
112  * This function initializes and makes sure that all fields will follow the CPU
113  * endianness. Due to that, the content of the buffer may change.
114  *
115  * Currently, no memory is allocated internally.
116  *
117  * @return On success, it returns the size of the allocated struct.
118  *	   A negative value indicates an error.
119  */
120 int dvb_desc_sat_init (
121     dvb_v5_fe_parms* parms,
122     const(ubyte)* buf,
123     dvb_desc* desc);
124 
125 /**
126  * @brief Prints the content of the satellite delivery system descriptor
127  * @ingroup descriptors
128  *
129  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
130  * @param desc	pointer to struct dvb_desc
131  */
132 void dvb_desc_sat_print (dvb_v5_fe_parms* parms, const(dvb_desc)* desc);
133 
134 /**
135  * @brief converts from the descriptor's FEC into enum fe_code_rate,
136  *	  as defined by DVBv5 API.
137  */
138 extern __gshared const(uint)[] dvbs_dvbc_dvbs_freq_inner;
139 
140 /**
141  * @brief converts from the descriptor's polarization into
142  *	  enum dvb_sat_polarization, as defined at dvb-v5-std.h.
143  */
144 extern __gshared const(uint)[] dvbs_polarization;
145 
146 /**
147  * @brief converts from the descriptor's rolloff into  enum fe_rolloff,
148  *	  as defined by DVBv5 API.
149  */
150 extern __gshared const(uint)[] dvbs_rolloff;
151 
152 /**
153  * @brief converts from the descriptor's modulation into enum fe_modulation,
154  *	  as defined by DVBv5 API.
155  */
156 extern __gshared const(uint)[] dvbs_modulation;